<template>
    <div class="photoinfo-container">
        <h3>{{photoinfo.title}}</h3>
        <p class="subtitle">
            <span>发表时间：{{photoinfo.add_time | dataFormat}}</span>
            <span>点击：{{photoinfo.click}} 次</span>
        </p>
        <hr>
<!--        缩略图区域 -->
        <div>
            <vue-preview
                :list="list"
                :thumbImageStyle="{width: '80px', height: '80px', margin: '10px'}"
                :previewBoxStyle="{border: '1px solid #eee'}"
                :tapToClose="true"
            />
        </div>

<!--        图片内容区域-->
        <div class="content" v-html="photoinfo.content"></div>

<!--        评论子组件-->
        <cmt-box :id="imageid"></cmt-box>
    </div>
</template>

<script>
    import comment from '../news/comment.vue';
    export default {
        name: "PhotoInfo.vue",
        data(){
            return {
                imageid : this.$route.params.id,
                photoinfo : {},
                list : [
                ]
            };
        },
        created() {
            this.getPhotoInfo();
            this.getThumbs();
        },
        methods:{
            getPhotoInfo(){
                //获取图片的详情
                this.axios.get('/api/getimagesInfo/' + this.imageid).then(result => {
                    if(result.status === 200){
                        this.photoinfo = result.data[0];
                    }
                })
            },
            getThumbs(){
                //获取缩略图
                this.axios.get('/api/gethumimages/'+ this.imageid).then(results => {
                    if(results.status === 200){
                        this.list = results.data;
                    }
                })
            }
        },
        components:{//注册评论子组件
            'cmt-box' : comment,
        }
    }
</script>

<style scoped lang="scss">
    .photoinfo-container{
        padding:3px;
        h3{
            color:#26A2FF;
            font-size: .9em;
            text-align: center;
            margin:15px 0;
        }
        .subtitle{
            display: flex;
            justify-content: space-around;
        }
        .content{
            text-indent: 2em;
            font-size: .8em;
            line-height: 2em;
            color: #4c494b;
        }
    }
</style>